package com.example.concurrent.chapter06;

/**
 * @author Create By Liuqz
 * @date 2018/11/22 15:25
 *
 * 销毁ThreadGroup及其子ThreadGroup,在该ThreadGroup中的所有线程必须都是空的
 * 也就是说ThreadGroup或者子ThreadGroup所有的线程都已经停止运行
 * 如果有Active线程存在,调用destroy方法,则会抛出异常
 */
public class ThreadGroupDestroy {
    public static void main(String[] args) {
        ThreadGroup group = new ThreadGroup("TestGroup");

        ThreadGroup mainGroup = Thread.currentThread().getThreadGroup();

        System.out.println("group.isDestroyed() = " + group.isDestroyed());

        mainGroup.list();

        group.destroy();

        System.out.println("group.isDestroyed() = " + group.isDestroyed());
        mainGroup.list();

    }
}
